import axios from 'axios'

const service = axios.create({
  baseURL: import.meta.env.VITE_API_URL,
  timeout: 3000,
  withCredentials: true,
  headers: {
    'Content-Type': 'application/x-www-form-urlencoded',
    'X-Requested-With': 'XMLHttpRequest'
  }
})

export default function (options) {
  options.method = options.method || 'get'
  options.data = options.data || {}
  if (options.method.toLowerCase() == 'get') {
    options.params = options.data
  }
  return service(options)
}
